<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<c:if test="${not empty param.xmlstr}">
<x:parse xml="${param.xmlstr}" var="xmlData" />
</c:if>
  <div class="bar_btn02">
          <c:set var="grantCode"><x:out select="$xmlData/data/proposal/grant_code" /></c:set>
				<span class="left"> 
					<input name="Submit" type="button" class="button_01" value="保存" onclick="saveAction()" /> 
					&nbsp; <c:if test="${not empty fbl.pdfViewUrl}"><input name="Submit" type="button" class="button_01" value="下载PDF"  onclick="genPdfAction()"/></c:if>
					<security:authorize ifNotGranted="A_DAILU_PROPOSAL">
					      <c:set var="depart_code"><x:out select="$xmlData/data/proposal/depart_code"/></c:set>
						   <c:if test="${empty depart_code}">
						   &nbsp; <input name="Submit" type="button" class="button_01"	value="提交给单位管理员" onclick="submitAction()" />
						   </c:if>
							<c:if test="${not empty depart_code}">
						   &nbsp; <input name="Submit" type="button" class="button_01"	value="提交给二级部门管理员" onclick="submitAction()" />
						   </c:if>
					</security:authorize>
					<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
					      <c:if test="${recomend_org_type=='17' }">&nbsp; <input name="Submit" type="button" class="button_01"	value="提交到县区主管单位" onclick="submitAction()" /></c:if>
					      <c:if test="${recomend_org_type!='17' }">&nbsp; <input name="Submit" type="button" class="button_01"	value="提交到归口管理部门" onclick="submitAction()" /></c:if>
					</security:authorize> 
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToList()" /> 
				</span>
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox2"/>
				</span>
				<c:if test="${not empty param.template }">
				<span class="right">
				<input name="Submit" type="button" class="button_01" value="填写说明" onclick="return ContentDownDesc('${param.template}');" />&nbsp;&nbsp;
				</span>
				</c:if>
				  <!--    重点研发计划--科技合作领域不需要填写检查 -->
				<c:set var="sub_grant_code" scope="request"><x:out select="$xmlData/data/proposal/sub_grant_code" /></c:set>
				<c:if test="${sub_grant_code != 2919 }">
				<span class="right"> <cpt:prpFile fileType="filldescription"
						grantCode="${sub_grant_code}" showName="填写说明"></cpt:prpFile>
				</span>
				</c:if>	
				
</div>
<script type="text/javascript">
/**
 * 申请书提交方法
 */
function doSubmitAction() {
	/**
	 * 填写检查未通过
	 */
	
	now_psn=$("input[name='proposal/psn_code']").val();
	/*alert("now_psn="+now_psn+"  before_psn="+before_psn);*/
	if(now_psn!='' && (before_psn!=now_psn) &&  before_psn!=''){
		reLogin();
		return false;
	} 
	
	
	if (!check())
		return false;
	if(!beforeSubmit1()){
		return false;
	}
	prcWin.openWin();// 打开遮罩层 提前至此处
	beforeSave();
	var xmlData = prePareXmlData();
	$("#xmlData").val(xmlData);
	var options = {
		beforeSubmit : function() {
			//prcWin.openWin();// 打开遮罩层 //收集数据需要时间 提前至验证通过后
		

		}, // 表单提交前的回调函数
		success : function(data) {
			if (data == null || data == "") {
				scmError(irisNotes.saveErrorNote1);
				
			}else if(data.indexOf("<html>")>=0){
				scmError(irisNotes.saveErrorNote3);
				
			} else{ 
				var obj = eval("(" + data + ")");
				
				if(obj.checkList!=null){
					$("#posCode").val(obj.pos_code);
					$("#prp_version").text(obj.prp_version);
					var list = obj.checkList ;
					for ( var i = 0; i < list.length; i++) {
						irisValaddMsg(list[i]);
					}
					irisValShowMsg($("#wbox2"));
					
				} else if(obj.message=="isSessionError"){
					scmError(irisNotes.saveErrorNote6);	//会话互串，请打开另一个页面登录帐号后再保存申请书
					
				} else if(obj.message=="saveError"){
					scmError(irisNotes.saveErrorNote2);
				} else if (obj.message=="notOrg") {
					scmError(irisNotes.notOrg);
				} else if(obj.message=="sbrSubmit"){
					scmError(irisNotes.saveErrorNote4);
				
				} else if(obj.message=="sbdwSubmit"){
					scmError(irisNotes.saveErrorNote5);
				} else {
					var subGrantCode = $("#subGrantCode").val();
					var grantCode = $("#grantCode").val();
					var menuId = $("#menuId").val();
					var depart_code = $("#depart_code").val();
					var recomend_org_type = $("#recomend_org_type").val();
					showThickBox(ctx + "/proposal/prpsubmitokZrjj?grantCode="
							+ grantCode + "&subGrantCode="+subGrantCode+ "&recomend_org_type="+recomend_org_type+ "&depart_code="+depart_code+"&menuId=" + menuId
							+ "&TB_iframe=true&height=250&width=500", irisNotes.submitSuccessNote1);
				}
			}
			prcWin.closeWin();// 关闭遮罩层
		},
		error : function() {
			prcWin.closeWin();// 关闭遮罩层
			scmError(irisNotes.submitErrorNote1);
		},
		url : "/egrantweb/proposal/submit", // 请求URL,可覆盖form的action
		type : "post",// 提交方式 post,get
		timeout:120000
	};
	$("#mainForm").ajaxSubmit(options);
}
</script>